home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / quikc21.zip / QWIKDEMO.C < prev    next >
Text File  |  1989-07-06  |  34KB  |  1,082 lines

  1. /*===========================================================================*\
  2. | QWIKDEMO.C                                                ver 2.1, 07-06-89 |
  3. |                                                                             |
  4. | Demo has been programmed best for color cards in 25-line mode.              |
  5. | Do not terminate this program manually.                                     |                                             |
  6. |                                                                             |
  7. |  Copyright (c) 1988,1989 by James H. LeMay, All rights reserved.            |
  8. |                                                                             |
  9. |  Conversion to C by Jordan Gallagher / Wisdom Research                      |
  10. \*===========================================================================*/
  11.  
  12. #include <stdio.h>
  13. #include <conio.h>
  14. #include <stdlib.h>
  15. #include <string.h>
  16. #include <time.h>
  17. #include <dos.h>
  18. #include <math.h>
  19.  
  20. #include "qwikc21.h"
  21.  
  22. char ch;
  23. char lastmode;
  24. char step, colmax;
  25. char blkrow, blkcol, v;
  26. char numstr[80];
  27. char coll[3], colr[3];
  28. char saved_block[4000], popup_block[4000];
  29. int  brdrattr, wndwattr;
  30. int  i, count, fgrnd, bgrnd;
  31. long rnum;
  32.  
  33. char strng[40]={ " Q Screen Utilities " };
  34. char strng2[40]={ " QWIKC Screen Utilities  " };
  35. char data[9][40]=
  36. { "1", "22", "333", " Q Screen Utilities ", "Odd  Length", "Even  Length",
  37.   "18 characters wide", "19 characters width", "Margin to Margin width" };
  38. char pc[14][80]=
  39. { "COMPUTERS:           ADAPTERS:",
  40.   "------------------   ----------",
  41.   "IBM PC               MDA",
  42.   "IBM XT               CGA",
  43.   "IBM AT               EGA",
  44.   "IBM PCjr             MCGA",
  45.   "IBM PC Convertible   VGA",
  46.   "IBM PS/2 Model 25    8514/A",
  47.   "IBM PS/2 Model 30    Hercules:",
  48.   "IBM PS/2 Model 50      HGC",
  49.   "IBM PS/2 Model 60      HGC Plus",
  50.   "IBM PS/2 Model 70      InColor",
  51.   "IBM PS/2 Model 80",
  52.   "IBM 3270 PC" };
  53. char other[12][80]=
  54. { "qscrollup  - Qwik scroll up",
  55.   "qscrolldown- Qwik scroll down",
  56.   "qscrtovscr - block to virtual screen",
  57.   "qvscrtoscr - virtual screen to block",
  58.   "qreadstr   - reads string from screen",
  59.   "qreadchar  - reads char   from screen",
  60.   "qreadattr  - reads attr   from screen",
  61.   "qviewpage  - view any video page",
  62.   "qwritepage - write to any video page",
  63.   "qwrite_sub - for arrays/partial strings",
  64.   "qfillc     - a self-centering qfill",
  65.   "qattrc     - a self-centering qattr" };
  66. char crsr[12][80]=
  67. { "gotorc        - absolute cursor position",
  68.   "wherer        - absolute cursor row",
  69.   "wherec        - absolute cursor column",
  70.   "setcursor     - sets cursor mode",
  71.   "getcursor     - gets cursor mode",
  72.   "modcursor     - modifies cursor mode",
  73.   "cursor_initial   - cursor at startup",
  74.   "cursor_underline - normal cursor",
  75.   "cursor_halfblock - for insert editing",
  76.   "cursor_block     - for the nearsighted",
  77.   "A total of 41 utilities",
  78.   "optimizing in just 2.7k bytes or less!" };
  79. char init[10][80]=
  80. { "∙ Detects dual monitor/adapters for all",
  81.   "  systems listed on the previous page",
  82.   "∙ Identifies each system by name",
  83.   "∙ Gets system ID and submodel ID",
  84.   "∙ Gets CPU ID",
  85.   "∙ Sets far pointer for virtual screens",
  86.   "∙ Determines need for wait-for-retrace",
  87.   "∙ Gets screen dimensions: rows by cols",
  88.   "∙ Determines the number of video pages",
  89.   "∙ Sets 4 standard cursor shapes" };
  90. char eoss[4][80]=
  91. { " ∙ qwriteeos     - just like qwrite     ",
  92.   " ∙ qwriteeos_sub - just like qwrite_sub ",
  93.   " ∙ qfilleos      - just like qfill      ",
  94.   " ∙ qattreos      - just like qattr      " };
  95.  
  96. int wait=400;
  97. struct border_t {
  98.     char TL[2];
  99.     char TH[2];
  100.     char TR[2];
  101.     char LV[2];
  102.     char RV[2];
  103.     char BL[2];
  104.     char BH[2];
  105.     char BR[2];
  106. } border = { "╔", "═", "╗", "║", "║", "╚", "═", "╝" };
  107.  
  108. char bwcolors[4]={ BLACK, LIGHTGRAY, WHITE, LIGHTGRAY_BG };
  109.  
  110. #ifndef __TURBOC__
  111. union REGS mr;
  112. #define disable _disable
  113. #define enable _enable
  114. #define random(num)     (rand() % (num))
  115. #define randomize()     srand((unsigned)time(NULL))
  116. #define textmode(m)     { mr.h.ah=0; mr.h.al=m; int86(0x10,&mr,&mr); }
  117. #endif
  118.  
  119. #ifdef __TURBOC__
  120. #define tclock() (*(long far *)0x46CL)
  121. #else
  122. #define tclock() (*(long far *)(0x46CL+_z))
  123. #endif
  124.  
  125.  
  126. /******************************| check_zenith |*****************************\
  127. Since Zenith doesn't have snow on any CGAs, turn off snow checking.
  128. \***************************************************************************/
  129. void check_zenith(void)
  130. {
  131.     char tmp[10];
  132.  
  133.     movedata( 0xF000u, 0x800Cu, (unsigned)(((char far *)tmp)+1),
  134.                                 (unsigned)((char far *)tmp),     8 );
  135.     if(qsnow && (strncmp( tmp, "ZDS CORP", 8 )) == 0) {
  136.         qsnow=0;
  137.         cardsnow=0;
  138.     }
  139. }
  140.  
  141.  
  142. /******************************| closedemo |********************************\
  143. Exits the demo.
  144. \***************************************************************************/
  145. void closedemo(void)
  146. {
  147.     if(qvideo_mode <= C40) {
  148. #ifdef __TURBOC__
  149.         delay( wait*6 );
  150. #else
  151.         suspend( wait*6 );
  152. #endif
  153.         textmode( lastmode );
  154.     }
  155.  
  156.     gotorc( 24, 1 );
  157.  
  158.     setcursor( cursor_initial );
  159. }
  160.  
  161.  
  162. /*********************************| qbox |**********************************\
  163. qbox is an application of QWIKC Screen Utilities.  It can make fast
  164. pop-up menus.  See WNDWxx.ARC for more applications.
  165. \***************************************************************************/
  166. void qbox( char row, char col, char rows, char cols, int wndwattr,
  167.            int brdrattr, struct border_t *b )
  168. {
  169.     if(rows >=2 && cols >=2) {
  170.         qwrite(   row,        col,                        brdrattr, b->TL );
  171.         qfilleos(                         1,      cols-2, brdrattr, b->TH[0] );
  172.         qwriteeos(                                        brdrattr, b->TR );
  173.         qfill(    row+1,      col,        rows-2, 1,      brdrattr, b->LV[0] );
  174.         qfill(    row+1,      col+cols-1, rows-2, 1,      brdrattr, b->RV[0] );
  175.         qwrite(   row+rows-1, col,                        brdrattr, b->BL );
  176.         qfilleos(                         1,      cols-2, brdrattr, b->BH[0] );
  177.         qwriteeos(                                        brdrattr, b->BR );
  178.         qfill(    row+1,      col+1,      rows-2, cols-2, wndwattr, ' '  );
  179.     }
  180. }
  181.  
  182.  
  183. /********************************| waitkey |********************************\
  184. Displays a prompt and awaits a keypress.
  185. \***************************************************************************/
  186. void waitkey(void)
  187. {
  188.     qwrite( 25, crt_cols-19, SAMEATTR, "press any key ..." );
  189.     if( (ch=getch()) == 0 ) ch=getch();
  190.     else if(ch==27) {
  191.         closedemo();
  192.         exit(0);
  193.     }
  194. }
  195.  
  196.  
  197. /*******************************| clearscr |********************************\
  198. Clears the screen using the specified attribute.
  199. \***************************************************************************/
  200. void clearscr( int attr )
  201. {
  202.     qfill( 1, 1, crt_rows, crt_cols, attr, ' ' );
  203. }
  204.  
  205.  
  206. /*******************************| scatter |*********************************\
  207. Displays random boxes on the screen.
  208. \***************************************************************************/
  209. void scatter( char maxrows, char leftcol, char rightcol,
  210.               char botrow, char toprow )
  211. {
  212.     int a;
  213.     char row, col, rows, cols;
  214.  
  215.     rows=random(maxrows)+1;
  216.  
  217.     if(qvideo_mode <= C40) {
  218.         cols = rows + (rows >> 2);
  219.     } else {
  220.         cols = (rows << 1) + (rows >> 1 );
  221.     }
  222.  
  223.     col = leftcol + random( rightcol - leftcol - cols + 2 );
  224.     row = toprow + random( botrow - toprow - rows + 2 );
  225.  
  226.     if(qvideo_mode == MONO) {
  227.         a=bwcolors[ random(4) ];
  228.     } else {
  229.         fgrnd=random(16);
  230.         bgrnd=random(8);
  231.         if(bgrnd == fgrnd) ++fgrnd;
  232.         a=fgrnd + (bgrnd << 4);
  233.     }
  234.  
  235.     qfill( row, col, rows, cols, a, 178 );
  236. }
  237.  
  238.  
  239. /*******************************| explode |*********************************\
  240. Makes the screen "explode" with boxes.
  241. \***************************